<?php
// 前端

$router->get('/', function () use ($router) {
    return 'Study API';
});

$router->group(['prefix'=>'study-api'], function() use ($router) {
    $router->group(['middleware'=>['oauth.consumer:student', 'oauth.scope:student']], function() use ($router) {
        $router->get('/courses', 'CourseController@getList');
        $router->get('/courses/level/{level}', 'CourseController@getByLevel');

        $router->get('/courses/current', 'CourseController@current');
        $router->put('/courses/current', 'CourseController@updateCurrentCourse');

        $router->post('/courses/{courseId}', 'CourseController@change');

        $router->get('/lessons/histories', 'HistoryController@lessons');
        $router->get('/words/histories', 'HistoryController@words');

        $router->delete('/lessons/{lessonId}/history', 'HistoryController@deleteLesson');

        $router->get('/status', 'StatusController@index');
        $router->get('/recommend', 'StatusController@getRecommend');

        $router->get('/lessons/{lessonId}', 'LessonController@show');

        $router->post('/lessons/{lessonId}/game', 'LessonController@playGame');
        $router->get('/lessons/{lessonId}/winner', 'LessonController@winner');

        $router->get('/lessons/{lessonId}/sources', 'LessonController@getAllSources');
        $router->get('/lessons/{lessonId}/sections/{sectionId}', 'LessonController@getSection');

        $router->post('/lessons/{lessonId}/progress', 'LessonController@updateProgress');

        $router->get('/dubs', 'DubController@index');
        $router->get('/lessons/{lessonId}/dubs', 'DubController@show');
        $router->post('/lessons/{lessonId}/dubs', 'DubController@store');
        $router->delete('/lessons/{lessonId}/dubs', 'DubController@destroy');

        $router->post('/knowledge/{knowledgeId}', 'KnowledgeController@store');
        $router->delete('/knowledge/{knowledgeId}', 'KnowledgeController@destroy');
        $router->get('/knowledge/tags', 'KnowledgeController@getTags');
        $router->get('/tags/{tagId}/knowledge', 'KnowledgeController@getTagKnowledge');

        // 测试
        $router->get('/levels/words', 'LevelController@words');
        $router->get('/levels/{level}/sample', 'LevelController@sample');
        $router->post('/levels/test', 'LevelController@test');
    });

    // 分享
    $router->get('/share/course', 'ShareController@course');
    $router->get('/share/game', 'ShareController@game');
    $router->get('/share/dub', 'ShareController@dub');
});
